package com.ynu.springbootappdemo.controller;

import com.ynu.springbootappdemo.common.utils.BaseResponse;
import com.ynu.springbootappdemo.common.utils.ResultUtils;
import com.ynu.springbootappdemo.model.dto.file.UploadFileRequest;
import com.ynu.springbootappdemo.service.UploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 文件接口
 */
@Api(tags = "文件上传控制器")
@RestController
@RequestMapping("/file")
public class FileController {

    @Resource
    private UploadService uploadService;

    /**
     * 文件上传
     *
     * @param uploadFileRequest
     * @return
     */
    @PostMapping("/upload")
    @ApiOperation("上传文件")
    public BaseResponse<String> uploadFile(@ApiParam("文件上传对象") UploadFileRequest uploadFileRequest) {
        return ResultUtils.success(uploadService.uploadFile(uploadFileRequest,"Demo"));
    }


}
